package com.example.activitidemo.controller.common;

import com.example.activitidemo.dto.User1;
import com.example.activitidemo.dto.UserVO;
import com.example.activitidemo.service.event.AssigneeService;
import com.example.activitidemo.service.event.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @ProjectName: activitidemo
 * @Package: com.example.activitidemo.controller
 * @ClassName: CommonTurnController
 * @Description:
 * @Author: 张志鹏
 * @CreateDate: 2020-01-08 9:27
 * @UpdateUser: 更新者
 * @UpdateDate: 2020-01-08 9:27
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
@Controller
public class CommonTurnController {
    @Autowired
    private AssigneeService assigneeService;
    @Autowired
    private EventService eventService;

    @GetMapping("users-events-list")
    public String toList(Map<String, Object> map) {

        List<User1> all = assigneeService.findAll();
        List<UserVO> users = new ArrayList<>();
        all.forEach(user -> {
            UserVO userVO = UserVO.builder()
                    .name(user.getName())
                    .id(user.getId()).build();
            users.add(userVO);
        });
        map.put("users", users);
        return "event/users-events-list";
    }
}
